<?php
/**
 * 权限控制
 * User: wuhao
 * Date: 2017/3/17
 * Time: 9:38
 */
namespace app\backend\controller\traits;
use app\backend\model\Member;

trait AuthManager
{
    /**
     * 获取权限列表
     * @param $memberId  用户id
     * @param $dtype 角色类型
     * @return array
     */
    public function getPower($memberId, $dtype)
    {
        if ($dtype != 7) {
            $auth = load_config($dtype, 'auth');
        } else {//员工的数据库获取
            $memberModel = new Member();
            $auth = $memberModel->getMemberInfoById($memberId, 'member_auth');
            $auth = json_decode($auth['member_auth'], true);
        }

        return $auth;
    }

    /**
     * 获取具体操作对应的id
     * @param $key 键值
     * @return int
     */
    public function getOper($key)
    {
        $id = load_config($key, 'menu_name');
        return $id;
    }


    /**
     * @comment 获取员工的房源权限
     * @author wuhao
     * @param $memberId
     * @return array
     */
    public function houseAuth($memberId)
    {
        $memberModel = new Member();
        $auth = $memberModel->getMemberInfoById($memberId, 'house_auth');
        $auth = json_decode($auth['house_auth'], true);
        return $auth;
    }
}